package concurrent.tool;

import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CallableFureTest3 {

	public static void main(String[] args) throws ExecutionException, InterruptedException {
		
		System.out.println("开始。。。");
		
		ExecutorService exeService = Executors.newCachedThreadPool();
		CompletionService<Double> cs = new ExecutorCompletionService<Double>(exeService);
		for(int i = 0; i < 10; i++){
			
			cs.submit(new MyCallable());
		}
		
		for(int i = 0; i < 10; i++){
			
			System.out.println(cs.take().get());
		}
		
		Thread.sleep(3000); //代表要做一些其他的操作
		System.out.println("主线程执行完毕");
	}
}
